*************************************************************************************
* Do-file for all tables and figures included in "Self-Legitimation in the Face of  *
* Politicization: Why International Organizations Centralized Public Communication" * 
* NOTE: tables are generated using the package "Estout"; graphs are based on        *
* simulations using the package "Clarify" (Tomz et al.) but in the adapted version  *
* ("Clear-Plot") provided by Travis Braidwood for which the file "simqi.ado" has to *
* be replaced (see http://travisbraidwood.altervista.org/dataverse.html for details *
*************************************************************************************



use ComIOCent_replication.dta, clear


***************************************
** Fig1  ******************************
***************************************

twoway (line CENTRAL year), by(ID_IO) ytitle(Centralization) xtitle(, size(large)) xlabel(1950(65)2015, labsize(large)) xmtick(##65) title(, size(large))

graph save Graph ComIO_Fig1.gph, replace


***************************************
** Tab1 *******************************
***************************************


local VAR1 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget i.year

tsset ID_IO year

estimates drop _all

nbreg  CENTRAL  `VAR1' lav_rdcc_l , vce(cluster ID_IO)
estimates store M1

nbreg  CENTRAL  `VAR1' dProtest_l  if year>1976, vce(cluster ID_IO)
estimates store M2

nbreg  CENTRAL  `VAR1' dScandal_l , vce(cluster ID_IO)
estimates store M3

nbreg  CENTRAL  `VAR1' lnNProtest_l  if year>1976, vce(cluster ID_IO)
estimates store M4

nbreg  CENTRAL  `VAR1' lnNScandal_l , vce(cluster ID_IO)
estimates store M5

nbreg  CENTRAL  `VAR1' lav_rdcc_l dProtest_l dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M6

nbreg  CENTRAL  `VAR1' lav_rdcc_l dProtest_l dScandal_l , vce(cluster ID_IO)
estimates store M7

nbreg  CENTRAL `VAR1' lav_rdcc_l lnNProtest_l lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M8

nbreg  CENTRAL `VAR1' lav_rdcc_l lnNProtest_l lnNScandal_l , vce(cluster ID_IO)
estimates store M9

estout * using tab1.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)

** for alpha values

estout * using tab1eform.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) eform


***************************************
** Tab2 *******************************
***************************************


egen lav_rdcc_l_min = min(lav_rdcc_l) 
egen lav_rdcc_l_max = max(lav_rdcc_l)
gen lav_rdcc_l_01 = (lav_rdcc_l - lav_rdcc_l_min)/ (lav_rdcc_l_max - lav_rdcc_l_min)

egen lnNProtest_lmin = min(lnNProtest_l) 
egen lnNProtest_lmax = max(lnNProtest_l)
gen lnNProtest_l_01 = (lnNProtest_l - lnNProtest_lmin)/ (lnNProtest_lmax- lnNProtest_lmin)

egen lnNScandal_lmin = min(lnNScandal_l) 
egen lnNScandal_lmax = max(lnNScandal_l)
gen lnNScandal_l_01 = (lnNScandal_l - lnNScandal_lmin)/ (lnNScandal_lmax- lnNScandal_lmin)

local VAR1 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget i.year

tsset ID_IO year

** model 6

nbreg  CENTRAL  `VAR1' lav_rdcc_l_01  dProtest_l dScandal_l  if year>1976, vce(cluster ID_IO)
listcoef, help
listcoef, percent help


** model 7

nbreg  CENTRAL  `VAR1' lav_rdcc_l_01  dProtest_l dScandal_l , vce(cluster ID_IO)
listcoef, help
listcoef, percent help

** model 8

nbreg  CENTRAL `VAR1' lav_rdcc_l_01  lnNProtest_l_01  lnNScandal_l_01  if year>1976, vce(cluster ID_IO)
listcoef, help
listcoef, percent help

** model 9

nbreg  CENTRAL `VAR1' lav_rdcc_l_01  lnNProtest_l_01  lnNScandal_l_01  , vce(cluster ID_IO)
listcoef, help
listcoef, percent help


***************************************
** Fig2 *******************************
***************************************


clear all
set seed 0210
set scheme s2mono
set more off, perm 
use ComIOCent_replication.dta, replace

estsimp nbreg  CENTRAL  lav_rdcc_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lnNProtest_l lnNScandal_l byear_1954-byear_2014 , vce(cluster ID_IO)

local a =0 
setx mean 
setx lav_rdcc_l (`a') 
simqi, level(95)
macro list
scalar list 
postutil clear
postfile mypost prediction upper lower using simresults, replace 
noisily display "start"
set obs 10000 
while `a' <= 1.217  {
qui simqi , level(95)
scalar prediction = Pr
scalar upper = PrU
scalar lower = PrL
post mypost (prediction) (upper) (lower)
scalar drop prediction upper lower
local a = `a'+.05
setx lav_rdcc_l (`a') 
display "." _c 
}
display ""
postclose mypost 
use simresults, clear 
sum
gen MV = 0+.05*(_n-1) 
gsort prediction upper lower -MV 
version 11
graph twoway  line prediction MV, clwidth(medium) clcolor(black) clpattern(solid) sort || line lower MV, clpattern(dash) clwidth(thin) clcolor(black) sort ||   line upper  MV, clpattern(dash) clwidth(thin) clcolor(black) sort ytitle("Expected centralization (with 95%-confidence interval)") xtitle("Transnational Access") note("") legend(off)	 scheme(s1color)

graph save Graph ComIO_Fig2.gph, replace


***************************************
** Fig3 *******************************
***************************************


clear all
set seed 0210
set scheme s2mono
set more off, perm 
use ComIOCent_replication.dta, replace

estsimp nbreg  CENTRAL  lav_rdcc_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lnNProtest_l lnNScandal_l byear_1978-byear_2014 if year>1976, vce(cluster ID_IO)


local a =0 
setx mean 
setx lnNProtest_l (`a') 
simqi, level(95)
macro list
scalar list 
postutil clear
postfile mypost prediction upper lower using simresults, replace 
noisily display "start"
set obs 10000 
while `a' <= 3.7  {
qui simqi , level(95)
scalar prediction= Pr
scalar upper = PrU
scalar lower = PrL
post mypost (prediction) (upper) (lower)
scalar drop prediction upper lower
local a = `a'+.05
setx lnNProtest_l (`a') 
display "." _c 
}
display ""
postclose mypost 
use simresults, clear 
sum
gen MV = 0+.05*(_n-1) 
gsort prediction upper lower -MV 
version 11
graph twoway  line prediction MV, clwidth(medium) clcolor(black) clpattern(solid) sort || line lower MV, clpattern(dash) clwidth(thin) clcolor(black) sort ||   line upper  MV, clpattern(dash) clwidth(thin) clcolor(black) sort ytitle("Expected centralization (with 95%-confidence interval)") xtitle("Coverage of protest (logged)") note("") legend(off)	 scheme(s1color)

graph save Graph ComIO_Fig3.gph, replace

***************************************
** Fig4 *******************************
***************************************


clear all
set seed 0210
set scheme s2mono
set more off, perm 
use ComIOCent_replication.dta, replace

estsimp nbreg  CENTRAL  lav_rdcc_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lnNProtest_l lnNScandal_l byear_1954-byear_2014 , vce(cluster ID_IO)

preserve
local a =0 
setx mean 
setx lnNScandal_l (`a') 
simqi, level(95)
macro list
scalar list 
postutil clear
postfile mypost prediction upper lower using simresults, replace 
noisily display "start"
set obs 10000 
while `a' <= 2.1  {
qui simqi , level(95)
scalar prediction= Pr
scalar upper = PrU
scalar lower = PrL
post mypost (prediction) (upper) (lower)
scalar drop prediction upper lower
local a = `a'+.05
setx lnNScandal_l (`a') 
display "." _c 
}
display ""
postclose mypost 
use simresults, clear 
sum
gen MV = 0+.05*(_n-1) 
gsort prediction upper lower -MV 
version 11
graph twoway  line prediction MV, clwidth(medium) clcolor(black) clpattern(solid) sort || line lower MV, clpattern(dash) clwidth(thin) clcolor(black) sort ||   line upper  MV, clpattern(dash) clwidth(thin) clcolor(black) sort ytitle("Expected centralization (with 95%-confidence interval)") xtitle("Coverage of scandals (logged)") note("") legend(off)	 scheme(s1color)

graph save Graph ComIO_Fig4.gph, replace


***************************************
** Tab A.1 ****************************
***************************************

use ComIOCent_replication.dta, replace
collapse (min) yearmin=year (max) yearmax=year (count) ID_IO, by(IOAccro)
export excel using "TabA1.xls", firstrow(variables) replace


***************************************
** Tab A.3 ****************************
***************************************

use ComIOCent_replication.dta, replace

sum CENTRAL CODIF DEPART polity2r lav_rdcc_l dProtest_l lnNProtest_l dScandal_l lnNScandal_l local_imp_l msecurity mcommod mdevelop menviron mhuman mfinance mtech mtrade dbudget, separator(0) format



***************************************
** Tab A.4 ****************************
***************************************


tsset ID_IO year

estimates drop _all

nbreg  CENTRAL  lav_rdcc_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lnNProtest_l lnNScandal_l byear_1954-byear_2014, vce(cluster ID_IO)
estimates store M10

nbreg  CENTRAL  lav_rdcc_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lnNProtest_l lnNScandal_l byear_1978-byear_2014  if year>1976, vce(cluster ID_IO)
estimates store M11

estout * using tabA4.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)

** for alpha values

estout * using tabA4eform.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) eform


***************************************
** Tab A.5 ****************************
***************************************


local VAR2 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget i.year lav_rdcc_l

tsset ID_IO year

estimates drop _all

ologit  CENTRAL  `VAR2' dProtest_l dScandal_l if year>1976, vce(cluster ID_IO)
estimates store M12
ologit  CENTRAL  `VAR2' dProtest_l dScandal_l , vce(cluster ID_IO)
estimates store M13

ologit  CENTRAL  `VAR2' lnNProtest_l lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M14
ologit  CENTRAL  `VAR2' lnNProtest_l lnNScandal_l , vce(cluster ID_IO)
estimates store M15

tobit  CENTRAL  `VAR2' dProtest_l dScandal_l if year>1976, vce(cluster ID_IO) ll
estimates store M16
tobit  CENTRAL  `VAR2' dProtest_l dScandal_l , vce(cluster ID_IO) ll
estimates store M17

tobit  CENTRAL  `VAR2' lnNProtest_l lnNScandal_l if year>1976, vce(cluster ID_IO) ll
estimates store M18
tobit  CENTRAL  `VAR2' lnNProtest_l lnNScandal_l , vce(cluster ID_IO) ll
estimates store M19

estout * using tabA5.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)


***************************************
** Tab A.6 ****************************
***************************************


local VAR1 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lav_rdcc_l i.year

tsset ID_IO year

estimates drop _all

nbreg  CODIF  `VAR1' dProtest_l dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M20

nbreg  CODIF dProtest_l dScandal_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lav_rdcc_l i1960 i1970 byear_1980 byear_1982 byear_1984 byear_1986 byear_1988 byear_1990 byear_1992 byear_1994 byear_1996 byear_1998 byear_2000 byear_2002 byear_2004 byear_2006 byear_2008 byear_2010 byear_2012 byear_2014, vce(cluster ID_IO)
estimates store M21

nbreg  CODIF lnNProtest_l lnNScandal_l polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget lav_rdcc_l byear_1984 byear_1986 byear_1988 byear_1990 byear_1992 byear_1994 byear_1996 byear_1998 byear_2000 byear_2002 byear_2004 byear_2006 byear_2008 byear_2010 byear_2012 byear_2014 if year>1976, vce(cluster ID_IO) diff
estimates store M22
nbreg  CODIF  `VAR1' lnNProtest_l lnNScandal_l, vce(cluster ID_IO) diff 
estimates store M23

ologit  DEPART  `VAR1' dProtest_l dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M24
ologit  DEPART  `VAR1' dProtest_l dScandal_l, vce(cluster ID_IO)
estimates store M25

ologit  DEPART  `VAR1' lnNProtest_l lnNScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M26
ologit  DEPART  `VAR1' lnNProtest_l lnNScandal_l, vce(cluster ID_IO)
estimates store M27

estout * using tabA6.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)

** for alpha values

estout * using tabA6eform.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) eform



***************************************
** Tab A.7 ****************************
***************************************

local VAR1 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget i.year

tsset ID_IO year

estimates drop _all

nbreg  CENTRAL  `VAR1' lav_rdcc_l dProtest_l dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M28
nbreg  CENTRAL  `VAR1' l.lav_rdcc_l l.dProtest_l l.dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M29
nbreg  CENTRAL  `VAR1' ll.lav_rdcc_l ll.dProtest_l ll.dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M30
nbreg  CENTRAL  `VAR1' lll.lav_rdcc_l lll.dProtest_l lll.dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M31
nbreg  CENTRAL  `VAR1' llll.lav_rdcc_l llll.dProtest_l llll.dScandal_l  if year>1976, vce(cluster ID_IO)
estimates store M32

nbreg  CENTRAL  `VAR1' lav_rdcc_l dProtest_l dScandal_l, vce(cluster ID_IO)
estimates store M33
nbreg  CENTRAL  `VAR1' l.lav_rdcc_l l.dProtest_l l.dScandal_l, vce(cluster ID_IO)
estimates store M34
nbreg  CENTRAL  `VAR1' ll.lav_rdcc_l ll.dProtest_l ll.dScandal_l, vce(cluster ID_IO)
estimates store M35
nbreg  CENTRAL  `VAR1' lll.lav_rdcc_l lll.dProtest_l lll.dScandal_l, vce(cluster ID_IO)
estimates store M36
nbreg  CENTRAL  `VAR1' llll.lav_rdcc_l llll.dProtest_l llll.dScandal_l, vce(cluster ID_IO)
estimates store M37


estout * using tabA7.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)

** for alpha values

estout * using tabA7eform.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) eform


***************************************
** Tab A.8 ****************************
***************************************


local VAR1 polity2r local_imp_l mdevelop menviron mhuman mfinance mtech mtrade msecurity mcommod dbudget i.year

tsset ID_IO year

estimates drop _all


nbreg  CENTRAL `VAR1' lav_rdcc_l lnNProtest_l lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M38
nbreg  CENTRAL `VAR1' l.lav_rdcc_l l.lnNProtest_l l.lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M39
nbreg  CENTRAL `VAR1' ll.lav_rdcc_l ll.lnNProtest_l ll.lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M40
nbreg  CENTRAL `VAR1' lll.lav_rdcc_l lll.lnNProtest_l lll.lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M41
nbreg  CENTRAL `VAR1' llll.lav_rdcc_l llll.lnNProtest_l llll.lnNScandal_l if year>1976, vce(cluster ID_IO)
estimates store M42

nbreg  CENTRAL `VAR1' lav_rdcc_l lnNProtest_l lnNScandal_l, vce(cluster ID_IO)
estimates store M43
nbreg  CENTRAL `VAR1' l.lav_rdcc_l l.lnNProtest_l l.lnNScandal_l, vce(cluster ID_IO)
estimates store M44
nbreg  CENTRAL `VAR1' ll.lav_rdcc_l ll.lnNProtest_l ll.lnNScandal_l, vce(cluster ID_IO)
estimates store M45
nbreg  CENTRAL `VAR1' lll.lav_rdcc_l lll.lnNProtest_l lll.lnNScandal_l, vce(cluster ID_IO)
estimates store M46
nbreg  CENTRAL `VAR1' llll.lav_rdcc_l llll.lnNProtest_l llll.lnNScandal_l, vce(cluster ID_IO)
estimates store M47

estout * using tabA8.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001)

** for alpha values

estout * using tabA8eform.txt, replace style (tab) cells(b(star fmt(3)) se(par fmt(3))) stats(ll N N_clust, fmt(%9.3f %9.3f %9.3f %9.0f %9.0f)) legend starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) eform




